package schoolWork.work02;

public class VoterDemo {
    public static void main(String[] args) {
        Voter[] voters = new Voter[4];
        //创建投票人对象
        voters[0] = new Voter("zhaofang");;
        voters[1] = new Voter("sunhua");;
        voters[2] = new Voter("zhangli");;
        voters[3] = new Voter("lili");;
        //投票人投票
        voters[0].voteFor("ZhangSan");
        voters[1].voteFor("WangWu");
        voters[2].voteFor("WangWu");
        voters[3].voteFor("WangWu");
        //查找票数得票最多的任选与票数

        int indexMax = Voter.findMaxIndex();
        System.out.println("the max polls is:"+Voter.polls[indexMax]);
        System.out.println("the name is:"+Voter.candidates[indexMax]);
    }
}
